package grabana

Import Path
	github.com/K-Phoen/grabana (on go.dev)

Dependency Relation
	imports 14 packages, and imported by one package

Involved Source Files alerts.go apikeys.go client.go dashboards.go datasources.go Package grabana provides a developer-friendly way of creating Grafana dashboards. Whether you prefer writing **code or YAML**, if you are looking for a way to version your dashboards configuration or automate tedious and error-prone creation of dashboards, this library is meant for you. builder := dashboard.New( "Awesome dashboard", dashboard.VariableAsInterval( "interval", interval.Values([]string{"30s", "1m", "5m", "10m", "30m", "1h", "6h", "12h"}), ), dashboard.VariableAsQuery( "status", query.DataSource("prometheus-default"), query.Request("label_values(prometheus_http_requests_total, code)"), query.Sort(query.NumericalAsc), ), dashboard.Row( "Prometheus", row.WithTimeSeries( "HTTP Rate", timeseries.WithPrometheusTarget( "rate(promhttp_metric_handler_requests_total[$interval])", prometheus.Legend("{{handler}} - {{ code }}"), ), ), row.WithTable( "Threads", table.WithPrometheusTarget("go_threads"), table.HideColumn("Time"), table.AsTimeSeriesAggregations([]table.Aggregation{ {Label: "AVG", Type: table.AVG}, {Label: "Current", Type: table.Current}, }), ), row.WithStat( "Heap Allocations", stat.Unit("bytes"), stat.WithPrometheusTarget("go_memstats_heap_alloc_bytes"), ), ), dashboard.Row( "Some text, because it might be useful", row.WithText( "Some awesome html?", text.HTML("<b>lalalala</b>"), ), ), ) For a more information visit https://github.com/K-Phoen/grabana folders.go
Package-Level Type Names (total 7)
/* sort by: | */
APIKey represents an API key. ID uint Name string func (*Client).APIKeys(ctx context.Context) (map[string]APIKey, error)
APIKeyRole represents a role given to an API key. ( APIKeyRole) MarshalJSON() ([]byte, error) APIKeyRole : github.com/goccy/go-json.Marshaler APIKeyRole : encoding/json.Marshaler const AdminRole const EditorRole const ViewerRole
Client represents a Grafana HTTP client. APIKeys lists active API keys. AddAlert creates an alert group within a given namespace. ConfigureAlertManager updates the alert manager configuration. CreateAPIKey creates a new API key. CreateFolder creates a dashboard folder. See https://grafana.com/docs/grafana/latest/reference/dashboard_folders/ DeleteAPIKeyByName deletes an API key given its name. DeleteAlertGroup deletes an alert group. DeleteDashboard deletes a dashboard given its UID. DeleteDatasource deletes a datasource given its name. FindOrCreateFolder returns the folder by its name or creates it if it doesn't exist. GetDashboardByTitle finds a dashboard, given its title. GetDatasourceUIDByName finds a datasource UID given its name. GetFolderByTitle finds a folder, given its title. UpsertDashboard creates or replaces a dashboard, in the given folder. UpsertDatasource creates or replaces a datasource. func NewClient(http *http.Client, host string, options ...Option) *Client
CreateAPIKeyRequest represents a request made to the API key creation endpoint. Name string Role APIKeyRole SecondsToLive int func (*Client).CreateAPIKey(ctx context.Context, request CreateAPIKeyRequest) (string, error)
Dashboard represents a Grafana dashboard. FolderID int FolderTitle string FolderUID string FolderURL string ID int IsStarred bool Tags []string Title string UID string URL string func (*Client).GetDashboardByTitle(ctx context.Context, title string) (*Dashboard, error) func (*Client).UpsertDashboard(ctx context.Context, folder *Folder, builder dashboard.Builder) (*Dashboard, error)
Folder represents a dashboard folder. See https://grafana.com/docs/grafana/latest/reference/dashboard_folders/ ID uint ParentUID string Title string UID string func (*Client).CreateFolder(ctx context.Context, name string) (*Folder, error) func (*Client).FindOrCreateFolder(ctx context.Context, name string) (*Folder, error) func (*Client).GetFolderByTitle(ctx context.Context, title string) (*Folder, error) func (*Client).UpsertDashboard(ctx context.Context, folder *Folder, builder dashboard.Builder) (*Dashboard, error)
Option represents an option that can be used to configure a client. func WithAPIToken(token string) Option func WithBasicAuth(username string, password string) Option func NewClient(http *http.Client, host string, options ...Option) *Client
Package-Level Functions (total 3)
NewClient creates a new Grafana HTTP client, using an API token.
WithAPIToken sets up the client to use the given token to authenticate.
WithBasicAuth sets up the client to use the given credentials to authenticate.
Package-Level Variables (total 5)
ErrAlertNotFound is returned when the requested alert can not be found.
ErrAPIKeyNotFound is returned when the given API key can not be found.
ErrDashboardNotFound is returned when the given dashboard can not be found.
ErrDatasourceNotFound is returned when the given datasource can not be found.
ErrFolderNotFound is returned when the given folder can not be found.
Package-Level Constants (total 3)